package com.zpark.humpro.mapper;

import com.zpark.humpro.utils.JdbcUtil;

import java.sql.Connection;
import java.sql.PreparedStatement;
import java.sql.SQLException;

/**
 * 数据层实现类
 */
public class HumanMapperImpl implements HumanMapper {

    @Override
    public int addHuman(String name,int age,String adress){

        Connection conn = JdbcUtil.getConnection();
        String sql = "insert into person_tb(name,age,adress) value(?,?,?)";
        try {
            PreparedStatement stat = conn.prepareStatement(sql);
            stat.setString(1,name);
            stat.setInt(2,age);
            stat.setString(3,adress);
            return stat.executeUpdate();

        } catch (SQLException e) {
            //一般会将异常记录到日志中
            return 0;
        }


    }

}
